{include file="include/top"}
<style>
    td,.layui-table th{
        text-align: center;!important;
    }
    .layui-col-md12{
        display: flex;
    }
</style>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">会员管理</a>
            <a>
              <cite>伪会员列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" style="width: 100%;">
                <div class="layui-card-body ">
                    <div class="layui-row">
                        <form class="layui-form layui-col-md12 x-so" action="{:url('User/delList')}" method="get">
                            <input class="layui-input" placeholder="开始日" name="start" id="start" style="width: 15%;margin: 10px 10px 10px 0px">
                            <input class="layui-input" placeholder="截止日" name="end" id="end" style="width: 15%;margin: 10px 10px 10px 0px">
                            <div style="margin: 10px 10px 10px 0px;width: 120px;">
                            <select name="city" lay-verify="required">
                                <option value="">请选择</option>
                                <option value="us_uid">会员编号</option>
                                <option value="us_name">会员姓名</option>
                                <option value="us_phone">手机号</option>
                                <option value="us_pid">推荐人ID</option>
                            </select>
                            </div>
                            <input type="text" name="key"  placeholder="请输入搜索内容" autocomplete="off" class="layui-input" style="width: 15%;margin: 10px 10px 10px 0px"   >
                            <input class="layui-btn" name="sub" type="submit" value="搜索" style="margin: 10px 10px 10px 0px">
                        </form>
                    </div>
                    <table class="layui-table layui-form" >
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>会员编号</th>
                            <th>会员昵称</th>
                            <th>手机号</th>
                            <th>账户积分</th>
                            <th>最后登录时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="data"}
                        <tr>
                            <td>{$key+1}</td>
                            <td>{$data.us_uid}</td>
                            <td>{$data.us_name}</td>
                            <td>{$data.us_phone}</td>
                            <td>{$data.us_points}</td>
                            <td>{$data.us_atime|date="Y-m-d H:i:s",###}</td>
                            <td>伪删除</td>
                            <td>
                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="member_stop(this,'user','us_id','{$data.us_id}','us_state',1,'恢复')">
                                    <i class="layui-icon">&#xe669;</i>
                                </button>
                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="stateYes('{$data.us_uid}')">
                                    <i class="layui-icon">&#xe640;</i>
                                </button>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    //会员删除
    function stateYes(id) {
        layer.confirm('确认要删除此会员吗？（并且关于的此会员的所有数据都将删除！一但删除不可恢复！！！）',function(index) {
            $.ajax({
                type: 'post',
                url: '{:url("User/userDels")}',
                dataType: 'json',
                data: {id: id, state: 1},
                success: function (data) {
                    if (data.code > 0) {
                        layer.msg(data.msg, {icon: 1, time: 2000});
                        setTimeout(function () {
                            location.reload();
                        }, 1000);
                    } else {
                        layer.msg(data.msg, {icon: 5, time: 2000})
                    }
                }
            });
        });
    }
    function member_stop(obj,table,id,where,field,state,title){
        $.ajax({
            type: 'POST',
            url: '{:url("index/updateStatus")}',
            dataType: 'json',
            data : {table:table,id:id,where:where,field:field,state:state},
            success: function(data){
                if(data.code>0){
                    layer.msg('已'+title,{icon:1,time:1000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                }else{
                    layer.msg(title+'失败',{icon:5,time:1000});
                }
            },
            error:function(data) {
                console.log(data.msg);
            },
        });
    }
</script>
</html>